{% extends 'base_with_top_menu.html' %}

{% block title %}{{ copy.title|default_if_none:"Title undefined"}}{% endblock %}

{% block header %}Book copy{% endblock %}

{% block content %}
<div class="copy_contentWrapper">
    <h2 id="title"><span>Title: <a href="{% url book_one copy.book.id%}">{{ copy.title }}</a></span></h2>

    {% if perms.baseapp.change_bookcopy %}
    <div class="edit_copy"><a href="{% url copy_edit copy.id %}" title="Edit this book copy"><span>edit</span></a></div>
    {% endif %}

    <div class="copy_info">
        <ul class="spaces">
            <li class="book_authors">
                {% if copy.authors %}
                <span class="label">Authors</span>: {{ copy.authors|join:', '}}
                {% else %}
                    No authors.
                {% endif %}
            </li>
            <li class="book_shelf_mark"><span class="label">ID:</span> {{ copy.shelf_mark }} {% block rent_return %}{% endblock rent_return %}</li>
              <li class="costcenter">
                <span class="label">Cost Center</span>:
                {% if perms.baseapp.view_costcenter %}
                  <a href="{% url costcenter_one copy.cost_center.id %}">{{ copy.cost_center }}</a>
                {% else %}
                  {{ copy.cost_center }}
                {% endif %}
              </li>
            <li class="book_publisher"><span class="label">Publishing</span>: {{ copy.publication_nr }},
              {% if perms.baseapp.view_publisher and copy.publisher %}
                  <a href="{% url publisher_one copy.publisher.id %}">{{ copy.publisher }}</a>
              {% else %}
                  {{ copy.publisher }}
              {% endif %}
              {{ copy.year }}
            </li>
            <!-- <li class="desc_url"><a href='{{ copy.desc_url }}'>See external description</a></li> -->
            <li class="book_location"><span class="label">Location</span>:
                {% if copy.location_url and perms.baseapp.view_location %}
                    <a href="{{copy.location_url}}">{{ copy.location }}</a>
                {% else %}
                    {{ copy.location }}
                {% endif %}
            </li>
        </ul>

    </div> <!-- /copy_info -->


    {% if 'Unavailable' not in copy.state %}
      {% block links %}
      {% endblock %}

      <!-- RENTAL FORM -->
      <div class="reserve_rent_form">
      {% block form %}
      {% endblock %}
      </div>
    {% endif %}


    <div class="availability">
      <h3 id="availability">Availability</h3>
      <div class="copy_info">
        <ul class="spaces">
        {% if 'Unavailable' in copy.state %}
          <li class="book_state"><span class="label">State</span>: <span class="unavailable">{{ copy.state }}</span></li>
        {% else %}
          <li class="book_state"><span class="label">State</span>: {{ copy.state|safe }}</li>
        {% endif %}
        </ul>
      </div>

      <!-- TIME BAR -->
      {% if display_time_bar %}
      <div class="time_barWrapper">
        {% include "time_bar/controls.html" %}
        {% include "time_bar/symbology.html" %}
        {% include "time_bar/standalone_copy_code.html" %}
      </div>
        {% endif %}
    </div>
    <!--  TOC  -->
    {% if copy.toc or copy.toc_url %}
    <h3 id="toc" class="book_toc">Table Of Contents</h3>
    <div class="book_tocWrapper">
      {% if copy.toc_url %}  <div class="book_toc_url">  <p><a href="{{ copy.toc_url }}">Click to see external table of contents.</a></p>  </div>   {% endif %}
      {% if copy.toc %}      <div class="book_toc">  {{ copy.toc|linebreaks }}  </div>    {% endif %}
    </div>
    {% endif %}

    <!--  DESC  -->
    {% if copy.desc or copy.desc_url %}
    <h3 id="description" class="book_desc">Description</h3>
    <div class="book_descWrapper">
      {% if copy.desc_url %}  <div class="book_desc_url">  <p><a href="{{ copy.desc_url }}">Click to see external description</a></p>  </div>    {% endif %}
      {% if copy.desc %}      <div class="book_desc">  {{ copy.desc|linebreaks }}  </div>     {% endif %}
    </div>
    {% endif %}
</div>
{% endblock %}
